<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    /**
     * Inicializuje globální nastavení aplikace
     *
     * @author Petr Laslo
     * @return Zend_Config
     */
    protected function __initConfig()
    {
        $config = $this->getOptions();
        Zend_Registry::set('config', $config);
        return $config;
    }

    /**
     * Inicializuje globalni menu z configs/menu.xml sekce navigation
     *
     * @author Premek Sumpela
     * @return Zend_Navigation
     */
    protected function _initNavigation()
    {

        $menu       = new Zend_Config_Xml(APPLICATION_PATH . '/configs/menu.xml', 'navigation');
        $navigation = new Zend_Navigation($menu);
        Zend_Registry::set('Zend_Navigation', $navigation);

        return $navigation;
    }

    /**
     * Inicializuje Access control list z configs/acl.ini
     *
     * @author Petr Laslo
     * @param void
     * @return void
     */
    protected function _initAcl()
    {
        $params = $this->getOptions();
        $db = Zend_Db::factory("pdo_mysql", $params["resources"]["db"]["params"]);
        Zend_Db_Table::setDefaultAdapter($db);
        Zend_Registry::set('acl', new Knihovna_Acl());
    }

    /**
     * Inicializuje Autoloader
     *
     * @author Petr Laslo
     * @param void
     * @return void
     */
    public function _initAutoload()
    {
        //nechce se jinak načíst formulář v modulu
        $autoloader = new Zend_Application_Module_Autoloader(array(
            'namespace' => 'Admin_',
            'basePath'  => APPLICATION_PATH .'/modules/admin',
            'resourceTypes' => array (
                'form' => array(
                    'path' => 'forms',
                    'namespace' => 'Form',
                ),
                'model' => array(
                    'path' => 'models',
                    'namespace' => 'Model',
                ),
            )
        ));
    }
}
